
<template>
	<div class="index">

		<div class="center">
			<left></left>
			<div class="right">
          <top></top>
          <!-- <div class="hei10"></div>
          <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">当前位置：分销后台><router-link to="/finance/dakuan">财务打款</router-link></div>
          --><div class="hei10"></div>

                <div class="powertop">
                <router-link class="powertopli powertopact" to="/finance/zhichu">佣金支出</router-link>
                <router-link class="powertopli " to="/finance/zhichu/tkzhichu">提卡费支出</router-link>
            </div>
                <div class="conlist" v-loading='loading'>
                    <div class="flex tktiao" style=" margin: 0 20px 0; width:1166px;">
                        <div class="tkli " @click="goto('zhichu')">佣金支出核算</div>
                        <div class="tkli" @click="goto('zhichu/querenzhichu')">佣金支出确认</div>
                        <div class="tkli tkact" @click="goto('zhichu/dakuan')">财务打款</div>
                    </div>
                    <div class="flex">
                        <div class="gong moneyf">
                            <el-form ref="form" @submit.native.prevent :model="form" label-width="100px" class="form">
                                <el-form-item label="提现申请人">
                                  <el-input v-model="shenqingren"></el-input>
                                </el-form-item>
                                <el-form-item label="打款状态:">
                                    <el-select v-model="qrstatus" placeholder="请选择">
<!--                                        <el-option label="还没生成报表" value="-1"></el-option>
                                        <el-option label="客户经理导出了" value="0"></el-option> -->
<!--                                        <el-option label="客户经理已确认" value="1"></el-option> -->
                                        <el-option label="未打款" value="2"></el-option>
                                        <el-option label="已打款" value="3"></el-option>
                                        <el-option label="全部" value="2,3"></el-option>
                                    </el-select>
                                </el-form-item>
                                <div class="gong" style="margin: 0 10px; position: relative;">
                                    <el-select v-model="timems" @change="timemschange" placeholder="时间选择" style="margin: 0 10px;">
                                        <el-option label="打款时间" value="0">打款时间</el-option>
                                        <el-option label="申请提现时间" value="1">申请提现时间</el-option>
                                    </el-select>
                                    <el-date-picker style="width: 350px;" :clearable='jinzhi' @change="timemschange" v-model="monthsearch" value-format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                                    <el-select v-model="iskptype" clearable placeholder="是否开票" style="margin: 0 10px;">
                                        <el-option label="不开票" value="1"></el-option>
                                        <el-option label="开票" value="2"></el-option>
                                    </el-select>
                                    <!-- <el-input style="width: 150px;" v-model="customername" placeholder="客户经理"></el-input> -->
                                   
									<el-select v-model="customername" filterable clearable placeholder="选择客户经理">
										<el-option v-for="(item,index) in listk" :key="index" :label="item.name" :value="item.id" ></el-option>
									</el-select>
								
                                </div>
                                <el-button type="danger" @click="search">搜索</el-button>
                                <el-button 
                                @click="openkp"
                                style="background-color: #F5F5F5;" round >配置开票信息</el-button>
                                <el-button 
                                @click="opendz"
                                style="background-color: #F5F5F5;" round  >配置发票收件地址</el-button>
                            </el-form>
                        </div>
                    </div>
                    <div style="padding-left: 20px; padding-bottom: 20px;"><el-button type="danger" @click="daochus">按检索结果导出财务明细</el-button> <el-button type="danger" style="margin-left: 30px;" @click="daochu2">导出银行信息</el-button><el-button type="danger" style="margin-left: 30px;" @click="daochus2">导出检索结果</el-button></div>
                    <div class="list">

                        <div class="th">提现ID</div>
                        <div class="th">申请提现人</div>

                        <!-- <div class="th">客户经理</div> -->
                        <div class="th" @click="orderby">提现申请时间
                          <i class="el-icon-sort-down" :class="[shunxu == 1?'actcolor':'']"></i>
                          <i class="el-icon-sort-up" style="margin-left: -15px;" :class="[shunxu == 0?'actcolor':'']"></i>
                        </div>
                        <div class="th">提现订单数量</div>
                        <div class="th">提现金额</div>
                        <div class="th">票据类型</div>
                        <div class="th">扣除税点金额</div>
                        <div class="th">实际支出金额</div>
                        <div class="th">票据介质</div>
                        <div class="th">结算状态</div>
                        <div class="th">打款时间</div>
                        <div class="th">操作</div>
                    </div>
                    <div class="list" v-for="item in list" :key="item.id">
                        <div class="td">{{item.id}}</div>
                        <div class="td">{{item.merchant}}</div>

                        <!-- <div class="td">{{item.count}}</div> -->
                        <div class="td">{{item.time}}</div>
                        <div class="td">{{item.count}}</div>
                        <div class="td">{{item.sum_amount | qux}}</div>
                        <div class="td">{{ item.type }}</div>
                        <div class="td">{{ item.invoice }}</div>
                        <div class="td">{{ item.real_amount }}</div>
                        <div class="td">
                            <span v-if="item.class==1">电子发票</span>    
                            <span v-if="item.class==2">纸质发票</span>    
                        </div>
                        <div class="td" v-if="item.transfer_time == null">未打款</div>
                        <div class="td" v-if="item.transfer_time != null">已打款</div>
                        <div class="td">{{item.transfer_time}}</div>
                        <div class="td" @click="chooseids(item.id)">

                            <el-button v-if="item.class==1" @click="checkpdf(item.e_invoice)" type="text" >查看发票</el-button>
                            <el-button v-if="item.class==2" @click="wuliuxiangqing(item)"  type="text" >查看邮寄单号</el-button>


                            <el-button v-if="item.image != null" type="text" @click="getbindcard(item.merchant_id,item.id,item.merchant,item.real_amount,item.image)">查看打款信息</el-button>
                            <el-button v-if="item.image == null" type="text" @click="getbindcard(item.merchant_id,item.id,item.merchant,item.real_amount,item.image)">录入打款信息</el-button>
                            <!-- <el-upload  v-if="item.image == null"  style="" list-type="picture" class="upload-demo" :show-file-list='false' action="https://jsonplaceholder.typicode.com/posts/" :http-request="upup3">
                              <el-button type="text" >录入打款信息</el-button>
                            </el-upload> -->
                        </div>
                    </div>
                    <div v-if="shopid == 304676 || shopid == 50481" class="t_heji">
                        <div>合计：</div>
                        <div style="margin-left: 20px;">提现订单数量合计：{{ total_count }}</div>
                        <div style="margin-left: 20px;">提现金额合计：{{ total_sum_amount }}</div>
                        <div style="margin-left: 20px;">实际支出金额合计：{{ total_real_amount }}</div>
                    </div>
                    <el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="fanye" :page-size="pagesize" :total="total"></el-pagination>
                </div>
            </div>
        </div>

        <el-dialog :title="choose.mobile" :visible.sync="tongjilog" width="400px" :close-on-click-modal='false'>
            <div class="daowei">所属商品编码:<span class="daowei2">{{choose.good_sku}}</span></div>
            <div class="daowei">返利次数:<span class="daowei2">{{choose.cycle}}</span></div>
            <div class="daowei">已领取次数:<span class="daowei2">{{choose.rebate_cycle}}</span></div>
            <div class="daowei">已领取积分:<span class="daowei2">{{choose.points}}</span></div>
            <div class="daowei">已充值话费:<span class="daowei2">{{choose.recharged_amount}}</span></div>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="tongjilog = false">确 定</el-button>
            </span>
        </el-dialog>


        <el-dialog title="导入结果" :visible.sync="shoplog" :close-on-click-modal="false" width="600px">
              <div>
                  <div style="color: #077ECE; line-height: 30px;">成功{{shoplist.success}}条</div>
                  <div style="color: #DF3434; line-height: 30px;">失败及原因：
                      <div v-for="(item,i) in shoplist.erros" :key="i">
                          {{item}}
                      </div>
                  </div>
              </div>
              <div slot="footer" class="dialog-footer">
                  <el-button type="primary" size="small"  @click="shoplog = false">好的</el-button>
              </div>
        </el-dialog>
        <el-dialog title="修改返利领取时间" :visible.sync="monthfixlog" :close-on-click-modal="false" width="600px">
            <el-form ref="form" @submit.native.prevent label-width="80px">
                <el-form-item label="起始月份:">
                    <el-date-picker v-model="monthfix" type="month" value-format="yyyy-MM" placeholder="选择起始月份"> </el-date-picker>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                  <el-button type="primary" size="small"  @click="fixtimego">好的</el-button>
              </div>
        </el-dialog>
        <el-dialog title="查看打款详情" :visible.sync="dakuanlog" :close-on-click-modal="false" width="600px">
            <div>
              <img :src="imageurl"  style="width: 100%;"/>
            </div>
            <div slot="footer" class="dialog-footer">
                  <el-button type="primary" size="small"  @click="dakuanlog = false">好的</el-button>
              </div>
        </el-dialog>
        <el-dialog title="银行卡信息" :visible.sync="yinhang" :close-on-click-modal="false" width="600px">
            <div>
              <div class="yinhangrow">
                <div>开户银行：</div><div>{{yinhangkaxinxi.bank}}</div>
              </div>
              <div class="yinhangrow">
                <div>开户支行：</div><div>{{yinhangkaxinxi.open_bank}}</div>
              </div>
              <div class="yinhangrow"><div>开户人姓名：</div><div>{{yinhangkaxinxi.bank_person}}<el-button type="text" size="mini" @click="copy(yinhangkaxinxi.bank_person)">复制</el-button></div></div>
              <div class="yinhangrow"><div>银行卡账号：</div><div>{{yinhangkaxinxi.bank_account}}<el-button type="text" size="mini" @click="copy(yinhangkaxinxi.bank_account)">复制</el-button></div></div>
              <!-- <div class="yinhangrow"><div>银行卡开户地址：</div><div>{{yinhangkaxinxi.open_bank}}</div></div> -->
            </div>
        </el-dialog>

        <el-dialog :title="tixianxinxi.alt" center :visible.sync="dakuanlogs" :close-on-click-modal="false" width="800px">
              <div>
                  <div class="dakuanlog" style="display: flex;">

                    <!-- <div>ID:{{this.tixianxinxi.id}}</div>
                    <div>提现人:{{this.tixianxinxi.merchant}}</div> -->
                    <div>提现金额：<span style="color: #f00; font-weight: bold;">{{this.tixianxinxi.real_amount | qux}}</span></div>
                  </div>
                  <div style="display: flex; margin-top: 30px;">
                    <div style="width: 100px;">账户信息：</div>
                    <div style="background: #EAEAEA; width: 100%; padding: 30px;">
                      <div class="yinhangrow">
                        <div>开户银行：{{yinhangkaxinxi.bank}}</div>
                        <div>开户支行：{{yinhangkaxinxi.open_bank}}</div>

                      </div>

                      <div class="yinhangrow">
                        <div>开户人：{{yinhangkaxinxi.bank_person}}<el-button type="text" size="mini" @click="copy(yinhangkaxinxi.bank_person)">复制</el-button></div>
                        <div>开户人身份证号：{{yinhangkaxinxi.user_id_num}}<el-button type="text" size="mini" @click="copy(yinhangkaxinxi.user_id_num)">复制</el-button></div>
                        <div>银行卡账号：{{yinhangkaxinxi.bank_account}}<el-button type="text" size="mini" @click="copy(yinhangkaxinxi.bank_account)">复制</el-button></div>


                      </div>
                      <!-- <div>银行卡开户地址：{{yinhangkaxinxi.open_bank}}</div> -->
                    </div>
                  </div>
                  <div style="display: flex; margin-top: 30px;">
                    <div style="width: 100px;">打款截图：</div>
                    <div style="background: #FFFFFF; border: 2px #EAEAEA solid; width: 100%; padding: 30px; min-height: 300px; display: flex; justify-content: center; align-items: center;">

                        <div v-if="this.tixianxinxi.image == null">
                          <div>
                            <div style="text-align: center;"><img :src="weishangchuan" /></div>
                            <div style="color: #999;">CTRL+V直接粘贴打款截图</div>
                          </div>

                        </div>
                        <div v-if="this.tixianxinxi.image != null"><img :src="imageurl"  style="width: 100%;"/> </div>

                    </div>
                  </div>
              </div>

              <div slot="footer" class="dialog-footer" style="text-align: right;">
                  <el-button type="primary" size="small" :loading="dakuanzhuangtai"  @click="dakuanwancheng">打款完成</el-button>
              </div>
        </el-dialog>
        <!-- <foot></foot> -->
        <!-- 配置开票信息 -->
        <el-dialog
            title="开票信息"
            :visible.sync="isshowkp"
            width="630px"
            :close-on-click-modal="false"
            >
            <el-input
                type="textarea"
                :rows="8"
                placeholder="请输入内容"
                v-model="kpinfo">
            </el-input>
            <div style="text-align: center;margin-top: 25px;">
                <el-button type="primary" @click="savekp">保存</el-button>
            </div>
        </el-dialog>
        <!-- 邮寄地址 -->
        <el-dialog
            title="邮寄地址"
            :visible.sync="isshowdz"
            width="650px"
            :close-on-click-modal="false"
            >
            <div class="t_dz_input_box">
                <div class="t_dz_title">输入收件人</div>
                <el-input v-model='yjform.address_name' style="width: 220px;" placeholder="输入收件人"></el-input>
            </div>
            <div class="t_dz_input_box">
                <div class="t_dz_title">联系电话</div>
                <el-input v-model='yjform.address_mobile' style="width: 220px;" placeholder="输入联系电话"></el-input>
            </div>
            <div class="t_dz_input_box">
                <div class="t_dz_title">收件地址</div>
                <div>
                    <el-cascader style="width: 100%;margin-bottom: 10px;" @change="changeaddress" 
                    v-model="localcitycode"
                    :options="options">
                    </el-cascader>
                    <el-input v-model='yjform.address' style="margin-top: 15px;"  placeholder="请输入详细地址"></el-input>
                </div>
            </div>
            <div style="text-align: center;margin-top: 25px;">
                <el-button type="danger" round @click="savedz">保存</el-button>
            </div>
        </el-dialog>
        <!-- 物流弹窗 -->
        <el-dialog center  title="物流详情" :visible.sync="wuliuxiangqinglog" width="600px" :close-on-click-modal="false">
        <div style="margin-bottom: 20px;">物流单号：{{ wuliunum }}</div>
    	<div v-if="wuliuxiangqingall.Traces">
        <el-timeline>
            <el-timeline-item v-for="(activity, index) in wuliuxiangqingall.Traces" :key="index" :timestamp="activity.AcceptTime">
              {{activity.AcceptStation}}
            </el-timeline-item>
          </el-timeline>
    	</div>
      <div v-if="wuliuxiangqingall.Reason">{{wuliuxiangqingall.Reason}}</div>
    	<div slot="footer" class="dialog-footer">
    		<el-button type="danger" round @click="wuliuxiangqinglog = false">确 定</el-button>
    	</div>
    </el-dialog>
    </div>

</template>

<script>
    import axios from 'axios'
    import top from '@/components/top.vue'
    import left from '@/components/left.vue'
    import foot from '@/components/foot.vue'
    import moment from "moment";
    import UploadExcelComponent from "@/components/UploadExcel/index.vue";
    import qu0 from "../../../public/qu0.js"
    import {
		regionData,
		CodeToText,
		TextToCode
	} from "element-china-area-data";
    export default {
        components: {
            "left": left,
            "top": top,
            "foot": foot,
            UploadExcelComponent

        },
        name: "dakuan",
        data() {
            return {
                dakuanlogs:false,
                shenqingren:"",
                qrstatus:"2,3",
                qrmonth:"",
                form:{},
                monthfixlog:false,
                monthfix:"",
                monthfixall:{},
                wenjian:"",
                shoplog:false,
                shoplist:"",

                btnname:"点击导入",
                uploading:true,
                fanliuploadlog:false,
                uploadsuceess:"",
                uploadtimes:"",
                uploadmon1:"",
                uploadmon2:"",
                uploadmon3:"",
                uptime:"",
                month:"",
                monthsearch:'',
                total:0,
                pagesize:20,
                page:1,
                list:"",
                loading:true,
                mobile:"",
                sku:"",
                tongjilog:false,
                choose:{ },
                url:"",
                id:"",
                func_J02:false,
                leader:0,
                dakuanlog:false,
                start:"",
                end:"",
                start2:"",
                end2:"",
                chooseid:"",
                imageurl:"",
                yinhang:false,
                yinhangkaxinxi:"",
                tixianxinxi:{},
                shunxu:0,
                timems:"0",
                jinzhi:false,
                weishangchuan:'/91haoka_platform/static/zhantie.png',
                dakuanzhuangtai:false,
                isshowkp:false,
                isshowdz:false,
                options: regionData,
                localcitycode:'',
                wuliuxiangqinglog:false,
                wuliuxiangqingall:"",
                kpinfo:'',
                yjform:{
                    address_name:'',
                    address_mobile:'',
                    address_province:'',
                    address_city:'',
                    address_district:'',
                    address:'',
                },
                wuliunum:'',
                total_count:'',
                total_real_amount:'',
                total_sum_amount:'',
                iskptype:'',
                customername:'',
                listk:[],
                shopid: "",
            }
        },
        filters: {
            qux:function(dataStr){
                return qu0.qu0(dataStr)
            }
        },
        created() {
            this.url = window.location.origin+"/"

            //权限问题
            var user = JSON.parse(localStorage.getItem('USER'));
            this.user_func = user.functions
            for( var i in this.user_func){
                var func_number = this.user_func[i].code
                if(func_number.indexOf("J02") >= 0){ this.func_J02 = true }
                if(func_number.indexOf("J01") >= 0){ this.func_J01 = true }
                if(func_number.indexOf("J03") >= 0){ this.leader = 1 }
            }

            var shop = JSON.parse(localStorage.getItem('SHOP'));
            this.shopname = shop.shop_name
            var that = this

            // this.monthsearch = moment().format("YYYY-MM");
            // this.uploadmon1 = moment().subtract(1, 'months').format("YYYY-MM");
            // this.uptime = moment().format("YYYY-MM");
            // this.uploadmon2 = moment().format("YYYY-MM");
            // this.uploadmon3 = moment().add(1, 'months').format("YYYY-MM");

            // console.log(moment().format("YYYY-MM"))

            this.getlist()
            this.getlistk()
            //店铺权限问题
			this.shopid = JSON.parse(localStorage.getItem('SHOP')).shop_id;

        },
        mounted() {
           document.addEventListener('paste', this.getClipboardFiles)
        },
        methods: {
          timemschange:function(){
            console.log(this.monthsearch)
              if(this.monthsearch == null){
                return false
              }
              if(this.timems == 0){
                  this.start = this.monthsearch[0]
                  this.end = this.monthsearch[1]
                  this.start2 = ''
                  this.end2 = ''
              }
              if(this.timems == 1){
                  this.start2 = this.monthsearch[0]
                  this.end2 = this.monthsearch[1]
                  this.start = ''
                  this.end = ''
              }
          },
          dakuanwancheng:function(){

this.dakuanzhuangtai = true
            var that = this
            var params = new FormData();
            params.append('file',this.wenjian);
            params.append('id',this.tixianxinxi.id);

            axios.post("/api/plan-market/expend/caiwu/confirm", params)
                .then(function(response) {
                    if (response.data.msg.code == 0) {
                        that.$message.success("上传成功！");
                        that.dakuanlogs = false
                        that.loading = true
                        that.getlist()
                        that.dakuanzhuangtai = false
                    }else{
                        that.$message.error(response.data.msg.info);
                        that.dakuanzhuangtai = false
                    }
                })
          },
          //复制图片上传
          getClipboardFiles (event) {
            let items = event.clipboardData && event.clipboardData.items;
            let file = null



           if(this.dakuanlogs == true ){
               if (items && items.length) {
                 // 检索剪切板items
                 for (var i = 0; i < items.length; i++) {
                   if (items[i].type.indexOf('image') !== -1) {
                     file = items[i].getAsFile()
                   }
                 }
               }
               if (!file) {
                 this.$message.error('粘贴内容不是图片')
                 return;
               }

              this.wenjian = file
              var that = this
              var reader = new FileReader(), htmlImage;
              reader.onload = function(e) {
                  that.imageurl = e.target.result
                  that.tixianxinxi.image = e.target.result
              }
              reader.readAsDataURL(file);
            }


         },

        //跳转
          goto:function(url){
            this.$router.push('/finance/'+url)
          },
          //复制功能
          copy: function(t) {
            var that = this;
            this.$copyText(t).then(res => {
              that.$message.success("复制成功");
            });
          },
          //获取银行卡信息
            getbindcard:function(merchant_id,id,merchant,real_amount,image){
              var that = this
              this.tixianxinxi.id = id
              this.tixianxinxi.merchant = merchant
              this.tixianxinxi.real_amount = real_amount
              this.tixianxinxi.image = image
              this.imageurl = this.url + image

              this.tixianxinxi.alt='ID：'+id+'     提现人：'+merchant
              axios.get('/api/plan-market/commission/getbindcarddan?merchant_id='+merchant_id)
                .then(response => {
                  if(response.data.msg.code == 0){
                      that.yinhangkaxinxi = response.data.data
                      if(response.data.data.bank != ''){
                          that.dakuanlogs = true
                      }else{
                        that.$message.error("对方没有填写银行信息");
                      }
                  }else{
                      that.$message.error(response.data.msg.info);
                  }
                })
            },
            //
            dakuan:function(url){
                this.imageurl = this.url + url
                this.dakuanlog = true
            },
            timechange:function(){
                console.log(this.monthsearch)
                this.start = this.monthsearch[0]
                this.end = this.monthsearch[1]
            },
            //上传凭证
            upup3:function(file){
              this.wenjian = file.file
              var that = this
              var params = new FormData();
              params.append('file',this.wenjian);
              params.append('id',this.chooseid);
              axios.post("/api/plan-market/expend/caiwu/confirm", params)
                  .then(function(response) {
                      if (response.data.msg.code == 0) {
                          that.$message.success("上传成功！");
                          that.loading = true
                          that.getlist()
                      }else{
                          that.$message.error(response.data.msg.info);
                      }
                  })
            },
            deletes:function(id){
               var iid = id
               this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'warning'
                    }).then(() => {

                      var that = this
                      axios.post('/api/plan-market/income/delete',{id:iid})
                          .then(response => {
                              if(response.data.msg.code == 0){
                                  that.getlist()
                              }else{
                                  that.$message.error(response.data.msg.info);
                              }
                          })
                    })

            },
            chooseids:function(e){
              this.chooseid = e
            },
            // exportData(data) {
            //     console.log(data)
            //     var that = this;
            //     var list = [];
            //     for (var i = 0; i < data.results.length; i++) {
            //       var obj = {};
            //       obj["confirm"] = data.results[i]["是否确认"];
            //       obj["id"] = data.results[i]["id"];
            //       obj["commission_amount"] = data.results[i]["本次应发"];
            //       obj["amount"] = data.results[i]["本次实发"];
            //       list.push(obj);
            //     }
            //     axios.post('/api/plan-market/confirm/import',{data:list,id:this.id})
            //     	.then(response => {
            //     		if(response.data.msg.code == 0){
            //           that.shoplist = response.data.data
            //           that.shoplog = true
            //           that.loading = false
            //     		}else{
            //     			that.$message.error(response.data.msg.info);
            //     		}
            //     	})
            // },
            //统计
            tongji:function(id){
                var that = this
                axios.get('/api/plan-market/rebate/log/detail?log_id='+id)
                	.then(response => {
                		if(response.data.msg.code == 0){
                            that.choose = response.data.data
                		}else{
                			that.$message.error(response.data.msg.info);
                		}
                	})
                this.tongjilog = true
            },
            //修改时间
            fixtime:function(id,mobile,month){
                this.monthfixall.id = id
                this.monthfixall.mobile = mobile
                this.monthfixall.month = month
                this.monthfixlog = true
            },
            fixtimego:function(){

                var qtime = this.monthfixall.month.toString()
                qtime = qtime.substr(0,4) + '-' + qtime.substr(5,2)

                var that = this
                axios.post("/api/plan-market/rebate/log/cycle", {order_id:this.monthfixall.id,mobile:this.monthfixall.mobile,month_ago:qtime,month_now:this.monthfix})
                    .then(function(response) {
                        if (response.data.msg.code == 0) {
                            that.monthfixlog = false
                            that.getlist()
                        }else{
                            that.$message.error(response.data.msg.info);
                        }
                    })
            },
            //暂停领取
            stopget:function(id){
                this.loading = true
                var that = this
                axios.post("/api/plan-market/rebate/log/status", { log_id:id,status:-100})
                    .then(function(response) {
                        if (response.data.msg.code == 0) {
                            that.getlist()
                        }else{
                            that.$message.error(response.data.msg.info);
                        }
                    })
            },
            //开放领取
            startget:function(id){
                this.loading = true
                var that = this
                axios.post("/api/plan-market/rebate/log/status", { log_id:id,status:100})
                    .then(function(response) {
                        if (response.data.msg.code == 0) {
                            that.getlist()
                        }else{
                            that.$message.error(response.data.msg.info);
                        }
                    })
            },
            //导出
            daochu:function(){
                axios.get('/api/plan-market/rebate/export?&month='+this.monthsearch)
                	.then(response => {
                		if(response.data.msg.code == 0){
                            location.href = response.data.data
                		}else{
                			that.$message.error(response.data.msg.info);
                		}
                	})
            },
            search:function(){
                this.page = 1
                this.getlist()
            },
            //翻页
            fanye:function(page){
            	this.loading = true
            	this.page = page
            	this.getlist()
            },
            daochus:function(){
              axios.get('/api/plan-market/expend/caiwudetail/export?page='+this.page+'&page_size='+this.pagesize+'&merchant='+this.shenqingren+'&status='+this.qrstatus+'&start='+this.start+'&end='+this.end+'&start2='+this.start2+'&end2='+this.end2+'&type='+this.iskptype+'&customer='+this.customername)
              	.then(response => {
              		if(response.data.msg.code == 0){
                      location.href = response.data.data
              		}else{
              			this.$message.error(response.data.msg.info);
              		}
              	})
            },
            daochus2:function(){
              axios.get('/api/plan-market/expend/caiwulist/export?page='+this.page+'&page_size='+this.pagesize+'&merchant='+this.shenqingren+'&status='+this.qrstatus+'&start='+this.start+'&end='+this.end+'&start2='+this.start2+'&end2='+this.end2+'&type='+this.iskptype+'&customer='+this.customername+'&orderby='+this.shunxu)
              	.then(response => {
              		if(response.data.msg.code == 0){
                      location.href = window.origin+'/' +response.data.data
              		}else{
              			this.$message.error(response.data.msg.info);
              		}
              	})
            },
			daochu2:function(){
			  axios.post('/api/plan-market/merchant/banks/export')
			  	.then(response => {
			  		if(response.data.msg.code == 0){
			          location.href = response.data.data
			  		}else{
			  			this.$message.error(response.data.msg.info);
			  		}
			  	})
			},
            //排序
            orderby:function(){
              if(this.shunxu == 0){
                this.shunxu = 1
              }else{
                this.shunxu = 0
              }
              this.loading = true
              this.getlist()
            },
            //获取列表
            getlist:function(){
                var that = this
                axios.get('/api/plan-market/expend/caiwu/list?page='+this.page+'&page_size='+this.pagesize+'&merchant='+this.shenqingren+'&status='+this.qrstatus+'&start='+this.start+'&end='+this.end+'&orderby='+this.shunxu+'&start2='+this.start2+'&end2='+this.end2+'&type='+this.iskptype+'&customer='+this.customername)
                	.then(response => {
                		if(response.data.msg.code == 0){
                      that.list = response.data.data.data
                      that.total = response.data.data.total
                      that.loading = false
                      that.total_count = response.data.data.total_count
                      that.total_real_amount = response.data.data.total_real_amount
                      that.total_sum_amount = response.data.data.total_sum_amount
                		}else{
                			that.$message.error(response.data.msg.info);
                		}
                	})
            },
            //下面使用的格式化时间
            formatDate:function(numb) {
              const time = new Date((numb - 1) * 24 * 3600000 + 1)
              time.setYear(time.getFullYear() - 70)
              const year = time.getFullYear() + ''
              const month = time.getMonth() + ''
              let date = time.getDate() + ''
              if(time.getFullYear()%4 === 0){
                var X = moment([year, month, date]).subtract(1, 'days').format('YYYY-MM-DD');
              }else{
                var X = moment([year, month, date]).format('YYYY-MM-DD');
              }
              return X
            },
            //下载模板
            xiazai:function(){
                const a = document.createElement('a');
                a.setAttribute('download', '收入导入模板.xlsx');
                a.setAttribute('href', this.url+'91haoka_platform/static/Incomeupload.xlsx');
                a.click();
            },
            xiabiao:function(e){
                const a = document.createElement('a');
                a.setAttribute('href', this.url+e);
                a.click();
            },
            xiabiao2:function(e){
                const a = document.createElement('a');
                a.setAttribute('href', this.url+e);
                a.click();
            },
            upup:function(file){
              console.log(file.file)
              this.wenjian = file.file
              var that = this
              this.loading = true
              var params = new FormData();
              params.append('file',this.wenjian);
              axios.post("/api/plan-market/income/import", params)
                      .then(function(response) {
                          if (response.data.msg.code == 0) {
                              that.shoplist = response.data.data
                              that.shoplog = true
                              that.loading = false
                              that.getlist()
                          }else{
                              that.$message.error(response.data.msg.info);
                          }
                      })
            },
            upup2:function(file){
              this.wenjian = file.file
              var that = this
              this.loading = true
              var params = new FormData();
              params.append('file',this.wenjian);
              params.append('file_id',this.id);
              axios.post("/api/plan-market/confirm/import", params)
                  .then(function(response) {
                      if (response.data.msg.code == 0) {
                          that.$message.success("导入确认表成功！");
                          that.getlist()
                      }else{
                          that.$message.error(response.data.msg.info);
                      }
                  })
            },
            //选择地址
            changeaddress(val){
                
                this.yjform.address_province = this.changeCodeToText(val[0])
                this.yjform.address_city = this.changeCodeToText(val[1])
                this.yjform.address_district = this.changeCodeToText(val[2])
            },
            //地区编码转文字
            changeCodeToText(code){
                return CodeToText[code]
            },
            //地区文字转编码
            changeTextToCode(province,city,district){
                var citycode = [];
                try {
                    if (province != "") {
                        citycode.push(TextToCode[province].code);
                    }
                    if (city != "") {
                        citycode.push(
                        TextToCode[province][city].code
                        );
                    }
                    if (district != "") {
                        citycode.push(
                        TextToCode[province][city][district].code
                        );
                    }
                    this.localcitycode = citycode
                    this.yjform.address_province = province
                    this.yjform.address_city = city
                    this.yjform.address_district = district
                    
                }catch (e) {
                //手动
                    console.log("没有在组件库找到此地址");
                    
                }
            },
            //打开配置开票
            openkp(){
                this.isshowkp = true
                //获取开票信息和地址
                this.getkpordz()
            },
            //打开配置地址
            opendz(){
                this.isshowdz = true
                //获取开票信息和地址
                this.getkpordz()
            },
            //保存开票信息
            savekp(){
                axios.post("/api/plan-market/user/set/invoice/info",{info:this.kpinfo}).then(response => {
					if (response.data.msg.code == 0) {
                        this.isshowkp = false
                        this.$message({
                        message: '操作成功',
                        type: 'success'
                        });
					} else {
						this.$message.error(response.data.msg.info);
					}
				});
            },
            //保存开票地址
            savedz(){
                axios.post("/api/plan-market/user/set/invoice/address",this.yjform).then(response => {
					if (response.data.msg.code == 0) {
                        this.isshowdz = false
                        this.$message({
                        message: '操作成功',
                        type: 'success'
                        });
					} else {
						this.$message.error(response.data.msg.info);
					}
				});
            },
            //获取开票信息和地址
            getkpordz(){
                axios.get("/api/plan-market/user/get/invoice/info").then(response => {
					if (response.data.msg.code == 0) {
                        console.log('获取开票信息和地址')
                        console.log(response)
                        this.kpinfo = response.data.data.info
                        this.yjform.address_name = response.data.data.address_name
                        this.yjform.address_mobile = response.data.data.address_mobile
                        this.yjform.address = response.data.data.address
                        if(response.data.data.address_province==''){
                            this.localcitycode = ''
                        }else{
                            //地区文字转编码
                            this.changeTextToCode(response.data.data.address_province,response.data.data.address_city,response.data.data.address_district)
                        }
                        

					} else {
						this.$message.error(response.data.msg.info);
					}
				});
            },
            wuliuxiangqing:function(item){
              this.wuliunum = item.tracking_number
			  axios.get("/api/plan-market/commission/invoice/track",{
                params:{id:item.id}
              }).then(response => {
					if (response.data.msg.code == 0) {
						console.log('物流')
						console.log(response.data)
						this.wuliuxiangqingall = response.data.data
						if(this.wuliuxiangqingall && this.wuliuxiangqingall.Traces){
						this.wuliuxiangqingall.Traces = this.wuliuxiangqingall.Traces.reverse()
						}
						this.wuliuxiangqinglog = true
					} else {
						this.$message.error(response.data.msg.info);
					}
				});
            },
            //查看pdf
            checkpdf(pdf){
                console.log(pdf)
                window.open(pdf,'_blank')
            },
            //获取人员
			getlistk: function() {
				var that = this
				axios.get('/api/plan-market/user/userManagerList')
					.then(response => {
						if (response.data.msg.code == 0) {
							that.listk = response.data.data
						} else {
							if (response.data.msg.code == 50401) {
								that.$router.push({
									path: "/login"
								});
								return false
							}
							that.$message.error(response.data.msg.info);
						}
					})
			},
        }
    }
</script>
<style scoped>
.t_dz_input_box{
    display: flex;
    margin-bottom: 25px;
}
.t_dz_title{
    width: 120px;
    text-align: right;
    margin-right: 5px;
    margin-top: 10px;
}
.t_heji{
    display: flex;
    padding: 20px;
}
</style>
<style lang="scss" scoped>
    .index{
        .dakuanlog{ display: flex;
          div{ margin-right: 30px;}
        }
        .actcolor{ color: #1989FA !important;}
        .listupload{ font-size: 14px;
            .li{flex: 1; line-height: 38px; margin-top: 20px;}
        }
        .yinhangrow{ display: flex; line-height: 28px; margin-bottom: 10px;
          div{flex: 1;}
          span{ margin-left: 15px;}
          // div:nth-child(1){ color:#999; flex: 1; text-align: left; flex: 1;}
          // div:nth-child(2){ color:#666; flex: 1; margin-right: 10px;  flex: 1;
          //   span{ margin-left: 15px;}
          // }
        }
        .moneyf{
          .el-button--primary{ background: #409EFF; color: #ffffff; border: none; }
          .el-button{ height: 40px !important;}
          .el-date-editor.el-input, .el-date-editor.el-input__inner{ width: auto;}
        }
        .form{ display: flex;
          input{ width: 150px !important;}
        }
        .listth{ font-size: 14px;  border-bottom: 1px #EAEAEA solid; font-weight: bold;}
        .daowei{ margin-bottom: 20px;}
        .daowei2{ color: #DD2727; margin-left: 10px;}
        .moneylist{ display: flex;}
        .erimg{ width: 200px;}
        .red{ border: 1px #FF3B3B solid !important; color: #FF3B3B !important;}
        .moneylist div{ border: 1px #AAAAAA solid; width: 85px; height: 35px; line-height: 35px; text-align: center; margin-right: 10px; cursor: pointer;}

                .title{border-bottom: 1px #EAEAEA solid;  line-height: 45px; padding-left: 30px; font-size: 16px; background: #F9F9F9; color: #727272}


            .powertop{ display: flex; background:#f9f9f9; }
            .powertopli{ flex-basis: 160px; line-height: 45px; border-top: 4px #f9f9f9 solid; color: #727272; border-right: 1px #f9f9f9 solid; font-size: 14px; text-align: center;}
            .powertopact{ background: #FFFFFF; border-top: 4px #DD2727 solid;}
            .con{  background: #FFFFFF; padding: 30px 40px; display: flex; justify-content: space-between;
                .conleft{
                    .flex{ display: flex; margin-bottom: 20px;}
                    .gong{ margin-right: 30px; color: #333}
                }
                .conright{
                    .el-input__inner{ line-height: 40px !important; height: 40px !important;}
                }
            }
            .conlist{ padding-bottom: 20px; background: #FFFFFF; min-height: 800px;
                .flex{ display: flex; justify-content: space-between; padding-top: 30px;}
                .tktiao{ margin-bottom: 20px;
                  .tkli{ flex: 1; text-align: center;  background: url(../../../static/img/changhui.png) no-repeat; line-height: 38px; cursor:pointer;}
                  .tkact{ background: url(../../../static/img/changhong.png) no-repeat; color:#FFFFFF;}
                }
                .gong{ display: flex;

                    .el-button--danger{ margin-left: 20px;}
                    .el-button--primary{ padding: 10px 30px; background: #EEF7FF; border: 1px #EEF7FF solid; }
                    .el-date-editor--month{ margin-right: 20px;}
                    button{  padding: 10px 20px;}
                }
                .gl{ margin-bottom: 20px;
                    .el-input__inner{ width: 200px !important; }
                    .el-button--danger{ margin-left: 0px !important; margin-right: 20px;}
                    .el-input__icon{ line-height: 36px;}
                }
                .list{ display: flex; border-bottom: 1px #eaeaea solid;
                    .th{ background: #EAEAEA; text-align: center; flex: 1; padding: 15px 0; font-size: 14px; line-height: 30px;
                      i{ font-size: 20px;font-weight: bold; color: #999; position: relative; top:3px}
                    }
                    .td{ background: #ffffff; text-align: center; flex: 1; padding: 5px 5px;  font-size: 14px;overflow: hidden;display: flex;align-items: center;flex-wrap: wrap;justify-content: center;}
                    .td2{ flex: 2; display: flex; justify-content: center; flex-wrap: wrap;}
                }
                .el-pagination{ text-align: right; margin: 20px 0}
            }

    }
</style>
